<?
header("Content-Type:text/html;charset=gb2312"); 
include ("usersystem/config/conf.php");
include ("usersystem/lib/mysqlClass.php");

$action=$_GET['action']?$_GET['action']:$_POST['action'];
$city=$_GET['city']?$_GET['city']:$_POST['city'];
$area1=$_GET['area1']?$_GET['area1']:$_POST['area1'];
$area2=$_GET['area2']?$_GET['area2']:$_POST['area2'];

$backMessage="info={backInfo:0}";
if($action=="getarea" && $city!="")
{
  $mysqlClass=new mysqlClass();
  $sql="select * from $areaTable where areaCitid=$city";
  $result=$mysqlClass->getRs($sql);
  $total=$mysqlClass->getRsCount($result);
  if($total>0)
  {
    $backMessage="info={backInfo:1,theValue:[";
     while($array=$result->fetch_array())
     {
       $backMessage.="{areaId:$array[areaId],areaName:'$array[areaName]'}";
	   if(($total-1)>0)
	    $backMessage.=",";
	   $total--;
     }
     $backMessage.="]}";
  }
  $mysqlClass->close();
}

if($action=="setarea" && $area1!="" && $area2!="" && $city!="")
{
  echo "sdfsdfsdfa";
  $mysqlClass=new mysqlClass();
  $sql="update $mediaTable set mtArea=".$area2." where mtArea=$area1";
  if($mysqlClass->update($sql))
  {
     $sql="delete from $areaTable where areaId=$area1";
	 if($mysqlClass->del($sql))
	 {
        $sql="select * from $areaTable where areaCitid=$city";
        $result=$mysqlClass->getRs($sql);
        $total=$mysqlClass->getRsCount($result);
        if($total>0)
        {
           $backMessage="info={backInfo:2,update:1,theValue:[";
           while($array=$result->fetch_array())
           {
             $backMessage.="{areaId:$array[areaId],areaName:'$array[areaName]'}";
	         if(($total-1)>0)
	          $backMessage.=",";
	         $total--;
           }
           $backMessage.="]}";
        }
	 }
  }
  $mysqlClass->close();
}


echo $backMessage;
	 
?>